package com.sskj.mine.verify;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.common.util.ClickUtil;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.mine.R;
import com.sskj.mine.R2;

import butterknife.BindView;

/**
 * @author Hey
 * Create at  2019/05/01
 */
//@Route(path = RConfig.MINE_VERIFY_RESULT)  // 认证成功  --  认证失败界面
public class VerifyResultActivity extends BaseActivity<VerifyResultPresenter> {
    @BindView(R2.id.verify_status)
    TextView verifyStatus;
    @BindView(R2.id.img)
    ImageView img;
    @BindView(R2.id.failed_reason)
    TextView failedReason;
    @BindView(R2.id.reset_verify)
    TextView resetVerify;
    @BindView(R2.id.verify_failed_rl)
    LinearLayout verifyFailedRl;
    @Autowired
    public boolean isSuccess;  // true 认证成功

    @Override
    public int getLayoutId() {
        return R.layout.mine_activity_verify_result;
    }

    @Override
    public VerifyResultPresenter getPresenter() {
        return new VerifyResultPresenter();
    }

    @Override
    public void initView() {
        ARouter.getInstance().inject(this);
        if (isSuccess) {
            setTitle(getString(R.string.mine_mineVerifyResultActivity1));
            verifyStatus.setVisibility(View.VISIBLE);
            verifyFailedRl.setVisibility(View.GONE);
        } else {
            setTitle(getString(R.string.mine_mineVerifyResultActivity2));
            verifyStatus.setVisibility(View.GONE);
            verifyFailedRl.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void initData() {
        if (!isSuccess) {
            mPresenter.verifyReason();
        }
    }

    @Override
    protected void initEvent() {
        ClickUtil.click(resetVerify, () -> {
            VerifySecondActivity.start(this);
            finish();
        });
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, VerifyResultActivity.class);
        context.startActivity(intent);
    }

}
